package com.beiye.drivertransport.adapter;

import android.content.Context;
import android.net.Uri;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.frame.adapter.CommonAdapter;
import com.android.frame.adapter.ViewHolder;
import com.beiye.drivertransport.R;
import com.beiye.drivertransport.bean.CheckUserIdBean;
import com.squareup.picasso.Picasso;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * Created by ky on 2018/6/4.
 */

public class HoleReforRecondApt extends CommonAdapter<CheckUserIdBean.RowsBean> {
    private final List<CheckUserIdBean.RowsBean> mList;
    private Context context;
    private String dateStr;


    public HoleReforRecondApt(Context context, List<CheckUserIdBean.RowsBean> mList, int itemLayoutId) {
        super(context, mList, itemLayoutId);
        this.context = context;
        this.mList = mList;
    }
    @Override
    public void convert(ViewHolder holder, CheckUserIdBean.RowsBean item, final int position) {
        TextView tv_date = holder.getView(R.id.tv_holerecond1);
        TextView tv_name = holder.getView(R.id.tv_holerecond3);
        TextView tv_through = holder.getView(R.id.tv_holerecond5);
        ImageView img_holerecond = holder.getView(R.id.img_holerecond);
        String userName = mList.get(position).getUserName();
        if(userName!=null)
        {
            tv_name.setText(userName);
        }else{
            tv_name.setText("");
        }
        long checkDate = mList.get(position).getCheckDate();
        if(checkDate>0)
        {
            Date date=new Date(checkDate);

            try {
                //yyyy表示年MM表示月dd表示日
                //yyyy-MM-dd是日期的格式，比如2015-12-12如果你要得到2015年12月12日就换成yyyy年MM月dd日
                SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd   HH:mm:ss");
                //进行格式化
                dateStr =sdf.format(date);
            } catch (Exception e) {
                e.printStackTrace();
            }
            tv_date.setText(dateStr);
        }else{
            tv_date.setText("");
        }
        Integer checkmark = mList.get(position).getCheckMark();
        if(checkmark==1)
        {
            tv_through.setText("审核通过");
        }else if(checkmark==2)
        {
            tv_through.setText("审核不通过");
        }
        String signPicUrl = mList.get(position).getSignPicUrl();

        Picasso.with(context).load(Uri.parse(signPicUrl)).placeholder(R.mipmap.no_data1).into(img_holerecond);//加载图片
    }


}